package com.lanou3g.mynewstest.module.person;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou3g.mynewstest.R;

import java.util.HashMap;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.wechat.friends.Wechat;

/**
 * Created by dllo on 16/1/19.
 */
public class PersonAdapter extends BaseAdapter {
    private Context context;
    private int ID[] = {R.mipmap.message, R.mipmap.goldmall, R.mipmap.task,
            R.mipmap.wallet, R.mipmap.offline, R.mipmap.promo,
            R.mipmap.gamecenter, R.mipmap.mail, R.mipmap.invitefriends};
    private String title[] = {"我的消息", "金币商城", "我的任务", "我的钱包", "离线阅读",
            "活动广场","游戏中心","我的邮箱","邀请好友"};

    public PersonAdapter(Context context) {
        this.context = context;

    }

    @Override
    public int getCount() {
        return 9;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_person, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        switch (position) {
            case 0:
                holder.textView.setText("评论我的跟帖/通知");
                break;
            case 2:
                holder.textView.setText("能赚能花,土豪当家!");
                break;
            case 7:
                holder.textView.setText("网易游戏年度大杂烩");
                break;
            case 9:
                holder.textView.setText("邀请好友送百兆流量");
                break;
            default:
                holder.textView.setText("");
                break;
        }
        holder.title.setText(title[position]);
        holder.imageView.setImageResource(ID[position]);

        return convertView;
    }

    class ViewHolder {
        TextView textView,title;
        ImageView imageView;
        public ViewHolder(View view) {
            textView = (TextView) view.findViewById(R.id.item_person_ad);
            title = (TextView) view.findViewById(R.id.item_person_title);
            imageView= (ImageView) view.findViewById(R.id.item_person_icon);
        }
    }

}
